﻿using System.Collections.Generic;

namespace UFrame
{
    /// <summary>
    /// 管理单例的一个类，所有单例都从这里取
    /// </summary>
    public class I
    {
        public static Dictionary<int, object> dic = new Dictionary<int, object>();

        public static T G<T>() where T : class
        {
            if (!dic.ContainsKey(typeof(T).GetHashCode()))
                return null;

            return dic[typeof(T).GetHashCode()] as T;
        }

        public static void A<T>(T t) where T : class
        {
            int id = typeof(T).GetHashCode();
            if (!dic.ContainsKey(id))
                dic.Add(id, t);
            else
                dic[id] = t;
        }
    }
}